package com.yckj.ytracker.api.config;

import com.yckj.ytracker.api.util.IPUtil;

/**
 * @author liuwei
 * @version 2017/10/16 上午11:45
 * @description 全局配置
 * @see
 * @since 1.0
 */
public class Global {

    /**
     * 采样频率
     */
    private int sample = 1;

    /**
     * 是否关闭调用链功能
     */
    private boolean closed = false;

    /**
     * 节点数量限制
     */
    private int limit = 100;

    /**
     * 本地IP
     */
    private String localIp;

    private Global() {
        try {
            localIp = IPUtil.getHostAddress();
        } catch (Exception e) {
            localIp = "127.0.0.1";
        }
    }

    private static class GlobalHolder {
        static Global instance = new Global();
    }

    public static Global getInstance() {
        return GlobalHolder.instance;
    }


    public int getSample() {
        return sample;
    }

    public void setSample(int sample) {
        this.sample = sample;
    }

    public boolean isClosed() {
        return closed;
    }

    public void setClosed(boolean closed) {
        this.closed = closed;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public String getLocalIp() {
        return localIp;
    }

    public void setLocalIp(String localIp) {
        this.localIp = localIp;
    }
}
